package com.itheima.array;

/*
     有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...定义一个方法求出这个数列的前20项之和
 */
public class WorkArray05 {
    public static void main(String[] args) {
        int num1 = 2;
        int num2 = 1;
        int temp = 0;
        int sum = 0;
        double[] arr = new double[20];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = num1 / num2;
            temp = num1;
            num1 += num2;
            num2 = temp;
            sum += arr[i];
        }
        System.out.println("和为"+sum);
    }
}
